package net.erl.objects.pattern.impl;

import net.erl.objects.ErlTerm;

import java.util.Map;

/**
 * I am but a simple pattern, that can only be used to match a constant term.
 */
public class ErlPatternImpl extends ErlPatternBase {

    private final ErlTerm term;

    public ErlPatternImpl(ErlTerm term) {
        this.term = term;
    }

    public Map<String, ErlTerm> matchAndSet(ErlTerm term, Map<String, ErlTerm> initialVars) {
        if (! this.term.equals(term)) {
            return null;
        }
        return ErlPatternBase.ensureVars(initialVars);
    }

}